import { Button, Space } from 'ant-design-vue';
import {
  PlusCircleOutlined,
  FilterOutlined,
  PlayCircleOutlined,
  PauseCircleOutlined,
  ClockCircleOutlined
} from '@ant-design/icons-vue';
import { defineComponent } from 'vue';

export default defineComponent({
  name: 'VxeTableToolButtons',
  props: {
    createCall: {
      type: Function,
      default: () => {}
    },
    deleteCall: {
      type: Function,
      default: () => {}
    },
    filterCall: {
      type: Function,
      default: () => {}
    },
    showDelete: {
      type: Boolean,
      default: true
    },
    showImport: {
      type: Boolean,
      default: true
    },
    showExport: {
      type: Boolean,
      default: true
    },
    showFilter: {
      type: Boolean,
      default: true
    }
  },
  emits: ['startAllJob', 'pauseAllJob', 'cancelSleep'],
  setup(_, { emit }) {
    const paddingLeft = 'padding-left:5px';
    const handleStartAllJob = () => {
      emit('startAllJob');
    };

    const handlePauseAllJob = () => {
      emit('pauseAllJob');
    };

    const handleCancelSleep = () => {
      emit('cancelSleep');
    };
    return {
      paddingLeft,
      handleStartAllJob,
      handlePauseAllJob,
      handleCancelSleep
    };
  },
  render() {
    return (
      <>
        <Space size={2} style={this.paddingLeft}>
          <Button
            type="primary"
            // v-permission="sysConfig:add"
            onClick={() => {
              this.createCall();
            }}
            icon={<PlusCircleOutlined />}
          >
            新增
          </Button>
          <Button
            type="primary"
            onClick={this.handleStartAllJob}
            // v-permission={'sysConfig:delete'}
            icon={<PlayCircleOutlined />}
          >
            启动所有作业
          </Button>
          <Button
            type="primary"
            // v-permission={'sysConfig:import'}
            icon={<PauseCircleOutlined />}
            onClick={this.handlePauseAllJob}
          >
            暂停所有作业
          </Button>
          <Button
            type="primary"
            // v-permission={'sysConfig:export'}
            icon={<ClockCircleOutlined />}
            onClick={this.handleCancelSleep}
          >
            强制唤醒作业调度器
          </Button>
          <Button
            v-show={this.showFilter}
            type="primary"
            onClick={() => {
              this.filterCall();
            }}
          >
            <FilterOutlined />
            过滤
          </Button>
        </Space>
      </>
    );
  }
});
